/**
 * 鼠标点击事件，判断是否登陆
 * @returns 
 */
function chkclick()
{
	var json_data = {};
	$.ajax({
	    type: 'GET',  //这里用GET
	    url: jiekou_site_url+'/user/checkask.html',
	    dataType: 'jsonp',  //类型
	    data: json_data,
	    jsonp: 'jcallback', //jsonp回调参数，必需
	    async: false,
	    success: function(d) { //返回的json数据
			if(d == 0) {
				alert('请先登陆');
				return false;
			}else if(d == 2) {
				alert('亲，只有融资顾问才能答复');
				return false;
			}
	    },
	    timeout: 3000
	});
}

//获取radio值
function getRadioValue(radioName) {
    var chkRadio = document.getElementsByName(radioName);
    for (var i = 0; i < chkRadio.length; i++) {
        if (chkRadio[i].checked)
            return chkRadio[i].value;
    }
}


/*
登录页清空功能
*/
function cancel()
{
	$('#account').val('');
	$('#password').val('');
	$('#code').val('');
}
/*
登录页验证码刷新
*/
function refurbish(){
     var img = document.getElementById("varImg"); 
     img.src = "inc/code.php?" + Math.random(); 
} 
/*
菜单列表JS代码
*/
function open_close_li(id)
{
	if(document.getElementById(id).style.display == "none") {
		document.getElementById(id).style.display = "block";
	}
	else {
		document.getElementById(id).style.display = "none";
	}
}
function open_close_item(id)
{
	if(document.getElementById(id).className == "openitem") {
		document.getElementById(id).className = "closeitem";
	}
	else {
		document.getElementById(id).className = "openitem";
	}
}
/*
时间代码
*/
function reloop()
{
	
	var time = new Date( ); //获得当前时间
	//获得年、月、日，Date()函数中的月份是从0－11计算
	var year = time.getYear(); 
	var month = time.getMonth()+1;
	var date = time.getDate();
	//获得小时、分钟、秒
	var hour = time.getHours();  
	var minute = time.getMinutes();
	var second = time.getSeconds();
	//获得一个星期中的第几天,西方的星期是从星期日开始，星期六结束
	var day = time.getDay();
	//如果分钟只有1位，补0显示
	if (minute < 10)
	minute="0"+minute;
	//如果秒数只有1位，补0显示
	if (second < 10)
	second="0"+second;
	//按12小时制显示
	if (hour>24) {
		hour=hour-24;
	}
	var weekday = 0;
	//firefox下的getyear是从1900年开始的
	year = (year < 1900)?(1900+year):year;
	
	switch(time.getDay()) {
		case 0:
			weekday = "星期日";
		break;
		case 1:
			weekday = "星期一";
		break;
		case 2:
			weekday = "星期二";
		break;
		case 3:
			weekday = "星期三";
		break;
		case 4:
			weekday = "星期四";
		break;
		case 5:
			weekday = "星期五";
		break;
		case 6:
			weekday = "星期六";
		break;
	}
	
	document.getElementById("t").innerHTML="今天是："+year+"年"+month+"月"+date+"日"+weekday+"  "+hour+"时"+minute+"分"+second+"秒";
	setTimeout("reloop()",1000);
}

function SetCookie(name,value)//两个参数，一个是cookie的名子，一个是值
{
    var Days = 180; //此 cookie 将被保存 30 天
    var exp  = new Date();    //new Date("December 31, 9998");
    exp.setTime(exp.getTime() + Days*24*60*60*1000);
    document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();
}
function getCookie(name)//取cookies函数        
{
    var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
     if(arr != null) return unescape(arr[2]); return null;

}
function delCookie(name)//删除cookie
{
    var exp = new Date();
    exp.setTime(exp.getTime() - 1);
    var cval=getCookie(name);
    if(cval!=null) document.cookie= name + "="+cval+";expires="+exp.toGMTString();
}

/**
 * 判断单选是否选中
 * @param rname
 * @returns {Number}
 */
function fn(rname){//定义一个函数 
	   var radio1=document.getElementsByName(rname);
    var flag1 = 0;
	   for(var i=0;i<radio1.length;i++)
	   {
	         if(radio1.item(i).checked==true)
	         {
	             flag1=1;
	             break;
	         }
	   }
	   return flag1;
}

function Counter(nMax,nInterval)
{
	this.maxTime=nMax;
	this.interval=nInterval;
	this.objId="timer";
	this.obj=null;
	this.num=this.maxTime;
	this.timer=null;
	this.start=function()
	{ 
		this.obj=document.getElementById(this.objId);
		if(this.num>0) setTimeout(this.run,this.interval*1000);
	};
	this.run=function()
	{
		if(myCounter.num>0) 
		{
			myCounter.num--;
			myCounter.obj.innerHTML=myCounter.num;
			myCounter.timer=setTimeout(myCounter.run,myCounter.interval*1000);
		}else{
			clearTimeout(myCounter.timer);
		}
	};
	this.show=function()
	{
		document.write("<span id="+this.objId+">"+this.num+"</span>");
		this.obj=document.getElementById(this.objId);
	//alert(this.obj.innerHTML);
	}
}

//判断单选框是否为空
function checkvalue(name){
	 var obj=document.getElementsByName(name);
	 var j = '';
	 //alert(obj.length);
	 for (var i=0;i<obj.length;i++){
		  if(obj[i].checked){
			  j = 1;
			  return j;
		  }
	 }
	 return j;
}